<html>
	<head>
		<meta charset="UTF-8">
		<title>login</title>
		<style type="text/css">
.bai {
	width: 100%;
	height: 800px;
	background-color: white;
	position: absolute;
	z-index: 5;
	/*display: none;*/
}
#btn {
	cursor: default;
	color: white;
	margin-top: 300px;
}
		</style>
	</head>
	<body>
<!--<div class="bai" id="bai"><span id="btn">hehe</span></div>-->
<p>现在时间：<span id="showtime" ></span></p>
	</body>
<script type="text/javascript">
//var btn=document.getElementById('btn');
//var tag = 1;
//btn.onclick = function(){
//	var bai=document.getElementById('bai');
//  if (tag == 1) {
//      tag++;
//  }else if(tag==8){
//      alert(tag);
//      bai.style.display="none";
//      tag++;
//  }else if(tag==999){
//  	alert('999');
//  	tag=1;
//  }else{
//  	tag++;
//  }
//}
	function getDate(){
		var date=new Date();
		var year=date.getFullYear();
		var month=date.getMonth()+1;
		var day=date.getDate();
		var weeks=["日","一","二","三","四","五","六"];
		var week=date.getDay();
		var hours=date.getHours();
		var min=date.getMinutes();
		var sec=date.getSeconds();
		var str =year+"-"+month+"-"+day+" 星期"+weeks[week]+" "+hours+":"+min+":"+sec;
		document.getElementById("showtime").innerHTML=str;
	}
	setInterval("getDate()",1000);
</script>
</html>

<?php
header("content-type:text/html;charset=utf-8");
$lifetime=10;
//session_set_cookie_params($lifetime);
session_start();
setcookie(session_name(),session_id(),time()+$_POST['ltime'],'/');
$zm='lyesswlqbj';
$arr=array(37575451,37575451,195956535,91515457,735356595,37575859,91515253,195958575,735352515,37575451);
$now=date('Y-m-d H:i:s');
$i=substr($now, -5,1);
$j=substr($now, -4,1);
$mm=$zm{$i}.$zm{$j}.$arr[$j];
echo $now."<br>";
echo "分钟的二位八码公式"."<br>";
echo mt_rand(100000,999999)."<br>";

if($_POST['dpwd']&&$_POST['dpwd']==$mm){
	$_SESSION['dpwd'] = 'dpwd';
	echo "<script>"; 
	echo "alert('对了 ~_~！');";
	echo "window.location.href='index.php';";
	echo "</script>";
}elseif($_POST['dpwd']&&($_POST['dpwd']!=$mm)){
	echo "<script>";
	echo "alert('错啦 -_-！');";
	echo "window.location.href='#';";
	echo "</script>";
}

if(!$_SESSION['dpwd']){
	echo "<form action='#' method='post'>
			<input type='text' name='dpwd' value='' /><br>
			<input type='text' name='ltime' value='3600' />
			<input type='submit' value='提交'/>
		</form>";
	exit();
}

echo "密码正确！";
?>